package tx.bj12320.model;

import javax.persistence.*;

import org.hibernate.annotations.GenericGenerator;

import javax.validation.constraints.*;
import org.hibernate.validator.constraints.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;

import java.util.*;

import javacommon.base.*;
import javacommon.util.*;

import cn.org.rapid_framework.util.*;
import cn.org.rapid_framework.web.util.*;
import cn.org.rapid_framework.page.*;
import cn.org.rapid_framework.page.impl.*;

import tx.bj12320.model.*;
import tx.bj12320.model.enums.ActivityEnum;
import tx.bj12320.dao.*;
import tx.bj12320.service.*;
import tx.bj12320.vo.query.*;


@Entity
@Table(name = "BJ12320_USER_INFO")
public class UserInfo extends BaseEntity implements java.io.Serializable{
	private static final long serialVersionUID = 5454155825314635342L;

	//alias
	public static final String TABLE_ALIAS = "用户信息";
	public static final String ALIAS_USER_INFO_ID = "userInfoId";
	public static final String ALIAS_ORG_INFO_ID = "orgInfoId";
	public static final String ALIAS_USER_NAME = "用户名";
	public static final String ALIAS_PASSWORD = "密码";
	public static final String ALIAS_REAL_NAME = "姓名";
	public static final String ALIAS_USER_CODE = "用户编码";
	public static final String ALIAS_CA_CODE = "CA编码";
	public static final String ALIAS_SYS_USER_TYPE = "所属系统类别组";
	public static final String ALIAS_IS_ORG_MANGER = "是否为单位管理员";
	public static final String ALIAS_AGENT_DN = "坐席工号";
	public static final String ALIAS_ORDER_INDEX = "顺序";
	public static final String ALIAS_IS_ADMINISTRATOR = "是否为超级管理员";
	public static final String ALIAS_STATUS = "用户状态";
	public static final String ALIAS_SELL_PHONE = "手机号";
	public static final String ALIAS_PHONE_NUM = "座机号";

	//date formats


	//可以直接使用: @Length(max=50,message="用户名长度不能大于50")显示错误消息
	//columns START
    /**
     * userInfoId       db_column: USER_INFO_ID
     */

	private Long userInfoId;
    /**
     * orgInfoId       db_column: ORG_INFO_ID
     */

	private Long orgInfoId;
    /**
     * 用户名       db_column: USER_NAME
     */
	@Length(max=100)
	private java.lang.String userName;
    /**
     * 密码       db_column: PASSWORD
     */
	@Length(max=100)
	private java.lang.String password;
    /**
     * 姓名       db_column: REAL_NAME
     */
	@Length(max=100)
	private java.lang.String realName;
    /**
     * 用户编码       db_column: USER_CODE
     */
	@Length(max=100)
	private java.lang.String userCode;
    /**
     * CA编码       db_column: CA_CODE
     */
	@Length(max=100)
	private java.lang.String caCode;
    /**
     * 所属系统类别组       db_column: SYS_USER_TYPE
     */
	@Length(max=100)
	private java.lang.String sysUserType;
    /**
     * 是否为单位管理员       db_column: IS_ORG_MANGER
     */

	private Long isOrgManger;
    /**
     * 坐席工号       db_column: AGENT_DN
     */
	@Length(max=100)
	private java.lang.String agentDn;
    /**
     * 顺序       db_column: ORDER_INDEX
     */

	private Long orderIndex;
    /**
     * 是否为超级管理员       db_column: IS_ADMINISTRATOR
     */

	private Long isAdministrator;
    /**
     * 用户状态       db_column: STATUS
     */

	private Long status;
	  /**
     * 手机号       db_column: SELL_PHONE
     */
	@Length(max=100)
	private java.lang.String sellPhone;
    /**
     * 座机号       db_column: PHONE_NUM
     */
	@Length(max=100)
	private java.lang.String phoneNum;
	//columns END


	public UserInfo(){
	}

	public UserInfo(
		Long userInfoId
	){
		this.userInfoId = userInfoId;
	}



	public void setUserInfoId(Long value) {
		this.userInfoId = value;
	}

	@Id	@GeneratedValue(strategy=GenerationType.SEQUENCE, generator="BJ12320_USER_INFO_SEQU")
    @SequenceGenerator(name="BJ12320_USER_INFO_SEQU",allocationSize=1,initialValue=1, sequenceName="BJ12320_USER_INFO_SEQU")
	@Column(name = "USER_INFO_ID", unique = true, nullable = false, insertable = true, updatable = true, length = 0)
	public Long getUserInfoId() {
		return this.userInfoId;
	}

	@Column(name = "ORG_INFO_ID", unique = false, nullable = true, insertable = true, updatable = true, length = 0)
	public Long getOrgInfoId() {
		return this.orgInfoId;
	}

	public void setOrgInfoId(Long value) {
		this.orgInfoId = value;
	}

	@Column(name = "USER_NAME", unique = false, nullable = true, insertable = true, updatable = true, length = 100)
	public java.lang.String getUserName() {
		return this.userName;
	}

	public void setUserName(java.lang.String value) {
		this.userName = value;
	}

	@Column(name = "PASSWORD", unique = false, nullable = true, insertable = true, updatable = true, length = 100)
	public java.lang.String getPassword() {
		return this.password;
	}

	public void setPassword(java.lang.String value) {
		this.password = value;
	}

	@Column(name = "REAL_NAME", unique = false, nullable = true, insertable = true, updatable = true, length = 100)
	public java.lang.String getRealName() {
		return this.realName;
	}

	public void setRealName(java.lang.String value) {
		this.realName = value;
	}

	@Column(name = "USER_CODE", unique = false, nullable = true, insertable = true, updatable = true, length = 100)
	public java.lang.String getUserCode() {
		return this.userCode;
	}

	public void setUserCode(java.lang.String value) {
		this.userCode = value;
	}

	@Column(name = "CA_CODE", unique = false, nullable = true, insertable = true, updatable = true, length = 100)
	public java.lang.String getCaCode() {
		return this.caCode;
	}

	public void setCaCode(java.lang.String value) {
		this.caCode = value;
	}

	@Column(name = "SYS_USER_TYPE", unique = false, nullable = true, insertable = true, updatable = true, length = 100)
	public java.lang.String getSysUserType() {
		return this.sysUserType;
	}

	public void setSysUserType(java.lang.String value) {
		this.sysUserType = value;
	}

	@Column(name = "IS_ORG_MANGER", unique = false, nullable = true, insertable = true, updatable = true, length = 0)
	public Long getIsOrgManger() {
		return this.isOrgManger;
	}

	public void setIsOrgManger(Long value) {
		this.isOrgManger = value;
	}

	@Column(name = "AGENT_DN", unique = false, nullable = true, insertable = true, updatable = true, length = 100)
	public java.lang.String getAgentDn() {
		return this.agentDn;
	}

	public void setAgentDn(java.lang.String value) {
		this.agentDn = value;
	}

	@Column(name = "ORDER_INDEX", unique = false, nullable = true, insertable = true, updatable = true, length = 0)
	public Long getOrderIndex() {
		return this.orderIndex;
	}

	public void setOrderIndex(Long value) {
		this.orderIndex = value;
	}

	@Column(name = "IS_ADMINISTRATOR", unique = false, nullable = true, insertable = true, updatable = true, length = 0)
	public Long getIsAdministrator() {
		return this.isAdministrator;
	}

	public void setIsAdministrator(Long value) {
		this.isAdministrator = value;
	}

	@Column(name = "STATUS", unique = false, nullable = true, insertable = true, updatable = true, length = 0)
	public Long getStatus() {
		return this.status;
	}

	public void setStatus(Long value) {
		this.status = value;
	}
	@Column(name = "SELL_PHONE", unique = false, nullable = true, insertable = true, updatable = true, length = 100)
	public java.lang.String getSellPhone() {
		return this.sellPhone;
	}

	public void setSellPhone(java.lang.String value) {
		this.sellPhone = value;
	}

	@Column(name = "PHONE_NUM", unique = false, nullable = true, insertable = true, updatable = true, length = 100)
	public java.lang.String getPhoneNum() {
		return this.phoneNum;
	}

	public void setPhoneNum(java.lang.String value) {
		this.phoneNum = value;
	}

	private Set infoissues = new HashSet(0);
	public void setInfoissues(Set<Infoissue> infoissue){
		this.infoissues = infoissue;
	}

	@OneToMany(cascade = { CascadeType.MERGE }, fetch = FetchType.LAZY, mappedBy = "userInfo")
	public Set<Infoissue> getInfoissues() {
		return infoissues;
	}

	private Set activityInfos = new HashSet(0);
	public void setActivityInfos(Set<ActivityInfo> activityInfo){
		this.activityInfos = activityInfo;
	}

	@OneToMany(cascade = { CascadeType.MERGE }, fetch = FetchType.LAZY, mappedBy = "userInfo")
	public Set<ActivityInfo> getActivityInfos() {
		return activityInfos;
	}

	private Set resources = new HashSet(0);
	public void setResources(Set<Resource> resource){
		this.resources = resource;
	}

	@OneToMany(cascade = { CascadeType.MERGE }, fetch = FetchType.LAZY, mappedBy = "userInfo")
	public Set<Resource> getResources() {
		return resources;
	}

	private OrgInfo orgInfo;
	public void setOrgInfo(OrgInfo orgInfo){
		this.orgInfo = orgInfo;
	}

	@ManyToOne(cascade = {}, fetch = FetchType.LAZY)
	@JoinColumns({
		@JoinColumn(name = "ORG_INFO_ID",nullable = false, insertable = false, updatable = false)
	})
	public OrgInfo getOrgInfo() {
		return orgInfo;
	}

	public String toString() {
		return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
			.append("UserInfoId",getUserInfoId())
			.append("OrgInfoId",getOrgInfoId())
			.append("UserName",getUserName())
			.append("Password",getPassword())
			.append("RealName",getRealName())
			.append("UserCode",getUserCode())
			.append("CaCode",getCaCode())
			.append("SysUserType",getSysUserType())
			.append("IsOrgManger",getIsOrgManger())
			.append("AgentDn",getAgentDn())
			.append("OrderIndex",getOrderIndex())
			.append("IsAdministrator",getIsAdministrator())
			.append("Status",getStatus())
			.append("SellPhone",getSellPhone())
			.append("PhoneNum",getPhoneNum())
			.toString();
	}

	public int hashCode() {
		return new HashCodeBuilder()
			.append(getUserInfoId())
			.toHashCode();
	}

	public boolean equals(Object obj) {
		if(obj instanceof UserInfo == false) return false;
		if(this == obj) return true;
		UserInfo other = (UserInfo)obj;
		return new EqualsBuilder()
			.append(getUserInfoId(),other.getUserInfoId())
			.isEquals();
	}

	private OrgInfo parentOrgInfo;

	@Transient
	public OrgInfo getParentOrgInfo() {
		return parentOrgInfo;
	}

	public void setParentOrgInfo(OrgInfo parentOrgInfo) {
		this.parentOrgInfo = parentOrgInfo;
	}
}

